package edu.whu.rose.clock.kps.algorithm.cbes;

public class IntArrayIterator implements Comparable<IntArrayIterator> {
	
	private int pos;
	
	private final int[] data;
	
	public IntArrayIterator(int[] data) {
		this.data = data;
		pos = -1;
	}
	
	public boolean hasNext() {
		if (pos < data.length - 1) {
			return true;
		}
		else {
			return false;
		}
	}
	
	public int next() {
		pos++;
		return data[pos];
	}
	
	public int peek() {
		return data[pos + 1];
	}

	public int compareTo(IntArrayIterator x) {
		if (peek() > x.peek()) {
			return 1;
		}
		else if (peek() < x.peek()) {
			return -1;
		}
		else {
			return 0;
		}
	}
	
}
